// pages/oder/index.js
var app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  userInfoHandler:function(e){
    var log = e.detail.errMsg
    var userMessage = e.detail.userInfo
    if(log==='getUserInfo:ok'){  // 用户让获取用户信息
      // console.log(e,'不会打印取消吧')
      app.globalData.userInfo=userMessage
      console.log(app.globalData.userInfo,'1')
      app.globalData.userShow=false
      // wx.setStorage({
      //   key:"userShow",
      //   data:"false"
      // })
      try {
        wx.setStorageSync('userShow', 'NO')
      } catch (e) { }
    }
  },
  tol:function(){
    this.setData({
      userShow:false
    })
  },
  emit:function(){
    this.setData({
      userShow:false
    })

  },
  detail:function(e){
    var item = e.currentTarget.dataset.item
     wx.navigateTo({
       url: '../detail/index',  //小程序传参url拼接?id=1&name=网二
       success:(res)=>{
         res.eventChannel.emit('para',item)
       }
     })
  },
  data: {
     value:'',
     index: 0,
     imgs:[
       'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606489956787&di=6ad92902db1c4fda9d3aca205cf8230f&imgtype=0&src=http%3A%2F%2Fa4.att.hudong.com%2F27%2F67%2F01300000921826141299672233506.jpg',
       'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606490019373&di=447cc35abe1fa002c1f3c4a52679ef92&imgtype=0&src=http%3A%2F%2Fa.hiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2Fa1ec08fa513d26974140252357fbb2fb4316d838.jpg',
       'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606490087821&di=0bb3cc8e1d326996b51fafa3c74b77e0&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Fa%2F54816319c9b40.jpg'
     ],
     arrList:[],
     userShow:app.globalData.userShow
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.request({
      url:'http://v.juhe.cn/toutiao/index',
     data:{
       type:'',
       key:'2efd8d4f6140e79dd895cd7e4a118387'
     },
      method:'GET',
      success:(res)=>{
        var ts = res.data.result.data
        that.setData({
          arrList:ts
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    console.log('onshow')
    console.log(app.globalData.userShow)
    this.setData({
      userShow:app.globalData.userShow
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})